package com.mdxx.xczd.db.dao;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import java.util.ArrayList;
import java.util.List;

public class LocationServerDAO extends ServerDAO{

	public LocationServerDAO(Context context) {
		super(context);
	}

	@Override
	public List<String> queryMulti(String sql) {
		List<String> list = new ArrayList<String>();
		SQLiteDatabase db = null;
		Cursor cursor;
		try {
			db = dbHelper.getWritableDatabase();
			cursor = db.rawQuery(sql, null);
			while (cursor.moveToNext()) {
				String location = cursor.getString(cursor.getColumnIndex("location"));
				list.add(location);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != db) {
				db.close();
			}
		}
		return list;
	}
	
	/*@Override
	public List<LocationAndNetWorkBean> queryMulti(String sql) {
		List<LocationAndNetWorkBean> list = new ArrayList<LocationAndNetWorkBean>();
		LocationAndNetWorkBean info = new LocationAndNetWorkBean();
		TimeInfoBean realTimeInfo = new TimeInfoBean();
		Coordinate coordinate = new Coordinate();
		Point clola = new Point();
		SQLiteDatabase db = null;
		Cursor cursor;
		try {
			db = dbHelper.getWritableDatabase();
			cursor = db.rawQuery(sql, null);
			while (cursor.moveToNext()) {
				for (int i = 0; i < cursor.getColumnCount(); i++) {
					String taskNum = cursor.getString(cursor.getColumnIndex("taskNum"));
					String cTime = cursor.getString(cursor.getColumnIndex("cTime"));
					double lo = cursor.getDouble(cursor.getColumnIndex("lo"));
					double la = cursor.getDouble(cursor.getColumnIndex("la"));
					String cellularSignalStrength = cursor.getString(cursor.getColumnIndex("cellularSignalStrength"));
					int networkStrength = cursor.getInt(cursor.getColumnIndex("networkStrength"));
					String cellID = cursor.getString(cursor.getColumnIndex("cellID"));
					String locationType = cursor.getString(cursor.getColumnIndex("locationType"));
					int satelliteNum = cursor.getInt(cursor.getColumnIndex("satelliteNum"));
					int power = cursor.getInt(cursor.getColumnIndex("power"));					
					clola.setLatitude(la);
					clola.setLongitude(lo);
					coordinate.setClola(clola);
					coordinate.setcTime(cTime);
					coordinate.setTaskNum(taskNum);
					realTimeInfo.setCellID(cellID);
					realTimeInfo.setCellularSignalStrength(cellularSignalStrength);
					realTimeInfo.setLocationType(Integer.valueOf(locationType));
					realTimeInfo.setNetworkStrength(networkStrength);
					realTimeInfo.setPower(power);
					realTimeInfo.setSatelliteNum(satelliteNum);
					info.setCoordinate(coordinate);
					info.setTimeInfoBean(realTimeInfo);
				}
				list.add(info);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != db) {
				db.close();
			}
		}
		return list;
	}*/
}
